package com.erp.module.dingDan

import android.content.Context
import android.util.Log
import com.erp.Interface.OnUserDataInterface
import com.erp.bean.OrderSousuoBean
import com.erp.contacts.Contacts
import com.erp.util.Httputil
import com.erp.util.Httputil.Call
import com.erp.util.Httputil.getparams
import org.xutils.http.RequestParams
import org.xutils.x

/**
 * Created by Administrator on 2019/3/14/014.
 * 作者：刘洋
 */
class DingDanModel :DingDanContract.DingDanMP{
    override fun getHttpOrder(context: Context, page: Int, pagesize: Int, bean: OrderSousuoBean, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.PRODUCTION)
        getparams(context, params)
        Httputil.setProsess(params)
        params.addBodyParameter("page", page.toString())
        params.addBodyParameter("pagesize", pagesize.toString())
        params.addBodyParameter("searchParams[all]", bean.all)
        params.addBodyParameter("searchParams[onum]", bean.onum)
        params.addBodyParameter("searchParams[o_contract_num_like]", bean.o_contract_num_like)
        params.addBodyParameter("searchParams[o_customer_like]", bean.o_customer_like)
        params.addBodyParameter("searchParams[province]", bean.province)
        params.addBodyParameter("searchParams[area]", bean.area)
        params.addBodyParameter("searchParams[o_type]", bean.o_type)
        params.addBodyParameter("searchParams[is_canceled]", bean.is_canceled)
        params.addBodyParameter("searchParams[field_empty]", bean.field_empty)
        params.addBodyParameter("searchParams[field_not_empty]", bean.field_not_empty)
        params.addBodyParameter("searchParams[shop_name_mh]", bean.shop_name)
        if (bean.special_service_cat.size > 0) {
            for (i in bean.special_service_cat.indices) {
                params.addBodyParameter("searchParams[special_service_cat][$i]", bean.special_service_cat[i])
            }
        }
        if (bean.time_category != "") {
            params.addBodyParameter("searchParams[time_filter][time_category]", bean.time_category)
            params.addBodyParameter("searchParams[time_filter][start_time]", bean.start_time)
            params.addBodyParameter("searchParams[time_filter][end_time]", bean.end_time)
        }
        Log.d("jsondata","http="+params.toString())
        x.http().get<String>(params, Call(context, onUserDataInterface))
    }
}